refactor(prisma-next)!: drop Encrypted prefix from v3 schema types; cipherstashFromStackV3 → cipherstashFromStack#685
Conversation
🦋 Changeset detectedLatest commit: 81726f4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughThis PR renames EQL v3 domain constructors and TypeScript factories to remove the ChangesEQL v3 API migration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
29d0ea5 to
65da67c
Compare
173092b to
d0ed74f
Compare
…s; cipherstashFromStackV3 -> cipherstashFromStack Aligns the EQL v3 authoring surface with the stack / Drizzle types.* catalog (the cipherstash. namespace already disambiguates): - v3 PSL column constructors drop the Encrypted prefix, at the single derivation seam (contract-authoring.ts v3PascalName): EncryptedTextSearch -> TextSearch, EncryptedDoubleOrd -> DoubleOrd, EncryptedBoolean -> Boolean, EncryptedJson -> Json, etc. - v3 one-call setup: cipherstashFromStackV3 -> cipherstashFromStack (v3 is the default); the v2 setup fn becomes cipherstashFromStackV2. Deliberately unchanged: - runtime value envelopes (EncryptedString/Number/BigInt/Date/Boolean/Json) — a separate write-side surface; Dan asked to leave them as-is. - the cipherstash.*V2 legacy column constructors. - generated contract.json + codec ids (they key off codecIds, not constructor names — so no contract regeneration needed, which sidesteps the broken on this branch). - the eql* query operators. - camelCase TS-authoring exports (encryptedTextSearch, …) keep their prefix for now — a follow-up will align them (kept v3CamelName unchanged to avoid desyncing the static exports). Namespace stays cipherstash (not eql): it is the extension's vendor identity (CIPHERSTASH_SPACE_ID, woven through every cipherstash/eql-v3/* codec id and cipherstash:* invariant) — switching it would re-identify the whole extension. Updated: example schema.prisma + db.ts + e2e, both READMEs, the stash-prisma-next skill, and the authoring/psl-interpretation tests. Verified: package builds clean, bundling-isolation 12/12, authoring/psl/column-types/ from-stack suites green, code:check clean. (Pre-existing env failures — live tests, properties, migration-v3 — are missing-devdep/DB issues, not this change.) Stacked on #683. v2 name per Dan; namespace + scope calls documented above. Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
…gree CI (Node 22/24 unit job) caught what my local env masked: test/v3/properties.test.ts asserts the PSL (pascal) and TS-authoring (camel) constructor names agree modulo first-letter case. My earlier deferral of the camelCase exports broke that invariant (pascal 'TextSearch' vs camel 'encryptedTextSearch'), and the property test only runs with fast-check installed (absent locally, present in CI). - v3CamelName drops the prefix too (encrypted<Core> -> lowercase-first<Core>), restoring the pascal/camel invariant. - The 31 static TS-authoring exports rename in lockstep: encryptedTextSearch -> textSearch, encryptedDoubleOrd -> doubleOrd, encryptedBoolean -> boolean, etc. (column-types.ts + its two test consumers). The v2 encryptedStringV2 descriptors and the runtime encrypted*ParamsSchema arktype schemas are deliberately untouched. - properties.test.ts: the assertion updated to the new convention (name does NOT start with 'Encrypted', is PascalCase, camel = lowercase-first(pascal)). - Changeset updated: camelCase exports move with the PSL names (no longer deferred). Ran the FULL prisma-next suite locally after `pnpm install` (which restored the missing devdeps my earlier local runs lacked): 599 passed / 30 skipped, including properties + column-types. Build clean, code:check clean. Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
…on names Follow-up to the camelCase rename: the 'no *OrdOre / no string factory' negative assertions checked old-convention names (encryptedBigIntOrdOre, encryptedString) that never existed either way — pass, but off-convention. Now check the new-convention names (bigIntOrdOre, textOrdOre, string). Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
d0ed74f to
4d906cc
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the @cipherstash/prisma-next EQL v3 authoring surface to align with the Stack/Drizzle types.* naming by removing the Encrypted prefix from v3 PSL constructors and making the v3 setup function the default cipherstashFromStack (with the v2 setup function renamed to cipherstashFromStackV2). It also propagates those renames through tests, examples, README, and the shipping stash-prisma-next skill, with a changeset capturing the breaking change.
Changes:
- Rename v3 PSL constructors from
cipherstash.Encrypted*()→cipherstash.*()and update the derivation seam (v3PascalName/v3CamelName). - Rename setup entry points:
cipherstashFromStackV3→cipherstashFromStack(v3), andcipherstashFromStack→cipherstashFromStackV2(v2). - Update skill/docs/examples/tests + add changeset documenting the breaking surface rename.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| skills/stash-prisma-next/SKILL.md | Update published skill guide to new v3 constructor + setup names. |
| packages/prisma-next/test/v3/properties.test.ts | Adjust property test to assert no Encrypted prefix for v3 constructors. |
| packages/prisma-next/test/v3/from-stack-v3.test.ts | Rename v3 setup function usage and test descriptions. |
| packages/prisma-next/test/v3/column-types.test-d.ts | Update dts tests for renamed TS factory exports. |
| packages/prisma-next/test/psl-interpretation.test.ts | Update PSL interpretation tests to new constructor names. |
| packages/prisma-next/test/live/side-by-side-clients-live-pg.test.ts | Update live coexistence test to use cipherstashFromStackV2 + v3 default name. |
| packages/prisma-next/test/live/helpers/harness.ts | Update live harness to call renamed v3 setup entry point. |
| packages/prisma-next/test/live/bulk-encrypt-live-pg.test.ts | Update live bulk-encrypt test header comment to new v3 setup name. |
| packages/prisma-next/test/from-stack-divergence.test.ts | Rename v2 divergence tests to cipherstashFromStackV2. |
| packages/prisma-next/test/column-types.test.ts | Update unit tests for renamed v3 TS factories. |
| packages/prisma-next/test/bundling-isolation.test.ts | Update bundling-isolation test commentary around marker choice. |
| packages/prisma-next/test/authoring.test.ts | Update authoring tests for new v3 constructor names. |
| packages/prisma-next/src/v3/from-stack-v3-validate.ts | Update v3 override validation error prefix to cipherstashFromStack. |
| packages/prisma-next/src/v3/derive-schemas-v3.ts | Update comments referencing v3 setup naming. |
| packages/prisma-next/src/stack/from-stack.ts | Rename v2 setup export to cipherstashFromStackV2 + adjust errors/docs. |
| packages/prisma-next/src/stack/from-stack-v3.ts | Rename v3 setup export to cipherstashFromStack + adjust errors/docs. |
| packages/prisma-next/src/exports/v3.ts | Re-export v3 setup function under the new default name. |
| packages/prisma-next/src/exports/stack.ts | Re-export v2 setup as cipherstashFromStackV2 and v3 setup as default. |
| packages/prisma-next/src/exports/column-types.ts | Rename v3 TS factory exports to match new constructor naming. |
| packages/prisma-next/src/contract-authoring.ts | Implement v3 naming transform without Encrypted prefix; adjust camelCase mapping. |
| packages/prisma-next/README.md | Update README examples and naming references for new setup/constructor names. |
| examples/prisma/test/e2e/str-range.e2e.test.ts | Update example test docs to reference cipherstash.TextSearch(). |
| examples/prisma/test/e2e/mixed.e2e.test.ts | Update e2e test to use cipherstashFromStack. |
| examples/prisma/src/db.ts | Update example app wiring to use cipherstashFromStack. |
| examples/prisma/README.md | Update example README constructor/setup names. |
| examples/prisma/prisma/schema.prisma | Update example schema to new v3 constructor names. |
| .changeset/prisma-next-drop-encrypted-prefix.md | Changeset documenting the breaking rename + skill update. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/prisma-next/README.md`:
- Around line 50-55: Update the quick start wiring snippet to call the v3
initializer cipherstashFromStack instead of cipherstashFromStackV2, while
keeping the existing contractJson argument and imports otherwise unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b9d9fe6a-1e61-4b3b-9253-45ebd937613a
📒 Files selected for processing (27)
.changeset/prisma-next-drop-encrypted-prefix.mdexamples/prisma/README.mdexamples/prisma/prisma/schema.prismaexamples/prisma/src/db.tsexamples/prisma/test/e2e/mixed.e2e.test.tsexamples/prisma/test/e2e/str-range.e2e.test.tspackages/prisma-next/README.mdpackages/prisma-next/src/contract-authoring.tspackages/prisma-next/src/exports/column-types.tspackages/prisma-next/src/exports/stack.tspackages/prisma-next/src/exports/v3.tspackages/prisma-next/src/stack/from-stack-v3.tspackages/prisma-next/src/stack/from-stack.tspackages/prisma-next/src/v3/derive-schemas-v3.tspackages/prisma-next/src/v3/from-stack-v3-validate.tspackages/prisma-next/test/authoring.test.tspackages/prisma-next/test/bundling-isolation.test.tspackages/prisma-next/test/column-types.test.tspackages/prisma-next/test/from-stack-divergence.test.tspackages/prisma-next/test/live/bulk-encrypt-live-pg.test.tspackages/prisma-next/test/live/helpers/harness.tspackages/prisma-next/test/live/side-by-side-clients-live-pg.test.tspackages/prisma-next/test/psl-interpretation.test.tspackages/prisma-next/test/v3/column-types.test-d.tspackages/prisma-next/test/v3/from-stack-v3.test.tspackages/prisma-next/test/v3/properties.test.tsskills/stash-prisma-next/SKILL.md
…README Copilot review on #685 — the rename left several references pointing at the old constructor names: - from-stack-v3.ts / from-stack.ts: the "no columns found" errors told users to declare `cipherstash.Encrypted*()` — now `cipherstash.*()` (e.g. `cipherstash.TextSearch()`) for v3 and `cipherstash.Encrypted*V2()` for v2. - contract-authoring.ts: the constructor-name doc said `Encrypted<Stem><Suffix>`; the prefix is dropped now (`eql_v3_bigint_ord` → `BigIntOrd`). - bundling-isolation.test.ts: the marker-collision note had the substring direction backwards post-rename — `cipherstashFromStackV2` is NOT a substring of the v3 `cipherstashFromStack`; the hazard is now the reverse. - README Quick start: the v3 schema example was wired to the v2 setup (`cipherstashFromStackV2` from `/stack`); use `cipherstashFromStack` from `/v3` so the snippet actually runs against a v3 contract. No behavioural change. prisma-next build + 599 tests green. Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
|
Human and I review (copilot and coderabbit). |
…shipped Dan's review on #691: the `stash eql migration --prisma` copy said the flag "ships with prisma-next EQL v3 support" / "not available yet" — but that support has shipped (#655/#683/#685), and Prisma Next installs EQL v3 through its OWN migration system (`prisma-next migration apply`), not through this command. Reframed all five spots to current reality (not "coming soon", but "use prisma-next migration apply"): the user-facing message + its doc comment, the `eqlMigrationCommand` code comment, the `--prisma` flag help in the registry, the changeset, and the stash-cli skill (which ships to customers). No behaviour change — `--prisma` still fails with a pointer. Build + 566 tests green. Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
…QL install) (#691) * feat(cli): add `stash eql migration --drizzle` (v3, migration-first EQL install) First of the three PRs in #690: make migration-first, ORM-agnostic EQL v3 install the front door, so every integration sources install SQL from one place (the CLI's bundled variants) instead of vendoring its own. This is the pattern that keeps Drizzle Supabase-safe; prisma-next's superuser-on-Supabase failure is fixed by the stacked follow-ups (`--prisma` emitter + removing prisma-next's baked baseline), which land on top of the prisma-next EQL v3 work (#655). `stash eql migration --drizzle [--supabase] [--name] [--out] [--dry-run]`: - Generates a Drizzle custom migration (via `drizzle-kit generate --custom`, then injects the SQL) carrying the bundled EQL **v3** install script + the `cs_migrations` tracking schema — one `drizzle-kit migrate` does everything `stash encrypt …` needs. - `--supabase` appends the v3 role grants (`eql_v3` + `eql_v3_internal` → anon/authenticated/service_role), matching `stash eql install --supabase`. - v3 only — no `--eql-version` (prisma-next never shipped v2). - `--prisma` is registered but fails with a pointer to #690 until the stacked PR. The SQL assembly (`buildEqlV3MigrationSql`) is a pure, unit-tested function; the drizzle-kit scaffold/inject orchestration reuses the proven helpers from the v2 `install --drizzle` path (`findGeneratedMigration`, `cleanupMigrationFile`, now exported). Registry + dispatch + help + `stash-cli`/`stash-drizzle` skills updated. Tests: 4 new unit (bundle present, grants gated on --supabase, tracking schema), 544 CLI unit green, manifest resolves the command, biome clean. Changeset: stash minor. Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w * fix(cli): harden `stash eql migration` per review (#691) Addresses the review on #691 — correctness, security, telemetry, and coverage: - Run the PROJECT-LOCAL drizzle-kit (`pnpm exec` / `npx --no-install`), not the `pnpm dlx`/`yarn dlx` download-and-run form, so it resolves the project's own drizzle.config.ts + schema. New shared `execCommand`/`execArgv` in init/utils (setup-prompt's private copy folded in). - Invoke via `spawnSync` with an argv array instead of `execSync` on a shell string — a `--name` with spaces or shell metacharacters is now one inert token (no word-splitting, no command injection). Plus a `[\w-]+` name guard. - Pass `--out` through to `drizzle-kit generate` (always) so the flag actually steers where the migration is written, and our lookup can't miss it. - Validation exits and every abort throw `CliExit(1)` instead of `process.exit`, so the telemetry `finally` runs and the branches are unit-testable. - Guard `loadBundledEqlSql` (corrupt bundle → clean error, not a fatal trace), add the missing `p.intro`, and call `printNextSteps()` so the now-preferred install path isn't less helpful than `eql install`. - HELP banner lists `eql migration`. Tests: 14 migration unit (target selection incl. `--supabase`-alone, name guard, dry-run, argv threading, non-zero drizzle-kit, write-failure cleanup, SQL order), 3 `findGeneratedMigration` unit (now public API), e2e smoke + `eql migration --help`. 557 unit / 65 e2e green, code:check clean. Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w * fix(cli): bun exec must not surprise-download; drop type-erased test cast CodeRabbit review on #691: - `execArgv`/`execCommand` bun case emitted `bun x`, which auto-installs a missing binary from npm — contradicting the "run a project-local binary, never surprise-download" contract these helpers exist to honour (the npm case already passes `--no-install`). Bun supports `--no-install`; pass it for both the argv and shell forms. Updated the setup-prompt assertion to match. - migration.test.ts: replaced the type-erasing `undefined as unknown as writeFileSync` hoisted-mock placeholder with a throwing placeholder cast to the specific type — fails loud if the mock factory never runs, and drops the `as unknown` (test files are plugin-exempt, but this is cleaner). CLI build + 566 unit tests green; biome clean. Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w * docs(cli): correct stale `--prisma` copy now that prisma-next v3 has shipped Dan's review on #691: the `stash eql migration --prisma` copy said the flag "ships with prisma-next EQL v3 support" / "not available yet" — but that support has shipped (#655/#683/#685), and Prisma Next installs EQL v3 through its OWN migration system (`prisma-next migration apply`), not through this command. Reframed all five spots to current reality (not "coming soon", but "use prisma-next migration apply"): the user-facing message + its doc comment, the `eqlMigrationCommand` code comment, the `--prisma` flag help in the registry, the changeset, and the stash-cli skill (which ships to customers). No behaviour change — `--prisma` still fails with a pointer. Build + 566 tests green. Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w * docs(cli): correct `--prisma` copy to match #690 (planned emitter, not "use prisma-next") My previous pass framed `--prisma` as "not supported — use `prisma-next migration apply`", which contradicts #690: the `--prisma` emitter IS a planned follow-up (PR3) that writes the install migration in the framework `Migration` shape and lets prisma-next DROP its baked install baseline. Pointing users at `prisma-next migration apply` is the very approach #690 replaces. Reframe all five spots to "not available yet — the Prisma Next emitter is a follow-up tracked in #690; use `--drizzle` today": the message + its doc comment, the `eqlMigrationCommand` code comment, the `--prisma` flag help, the changeset, and the stash-cli skill. (The `stash eql install` guard + stash-prisma-next skill keep their `prisma-next migration apply` wording — that correctly describes the current baked-baseline install, which is a different thing from this CLI emitter.) No behaviour change. Build + 566 tests green. Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
Renames the EQL v3 authoring surface to line up with the stack / Drizzle
types.*catalog, per Dan's #683 review (comments 3 & 4). Stacked on #683 so the package rename and the skill land together.What changed (public API)
Encrypted— thecipherstash.namespace already disambiguates:cipherstash.EncryptedTextSearch()→cipherstash.TextSearch(),EncryptedDoubleOrd()→DoubleOrd(),EncryptedBoolean()→Boolean(),EncryptedJson()→Json(), etc. Done at the single derivation seam (contract-authoring.tsv3PascalName).cipherstashFromStackV3→cipherstashFromStack(v3 is the default); the v2 setup fn becomescipherstashFromStackV2.encryptedin lockstep with the PSL constructors —encryptedTextSearch→textSearch,encryptedDoubleOrd→doubleOrd, etc. (v3CamelNamederives from the samecoreNameseam, and a property test enforces pascal/camel agree). The*V2factories keep their names.Deliberately unchanged
EncryptedString/EncryptedNumber/EncryptedBoolean/…) — a separate write-side surface; Dan asked to leave them.cipherstash.*V2legacy column constructors and theencrypted*V2camelCase factories.contract.json+ codec ids — they key off codec ids, not constructor names, so no contract regeneration is needed (which neatly sidesteps the brokenprisma-next contract emiton this branch — filed separately as it's pre-existing).eql*query operators.Decisions (yours, documented)
cipherstash, noteql. It's the extension's vendor identity (CIPHERSTASH_SPACE_ID, woven through everycipherstash/eql-v3/*codec id andcipherstash:*invariant) — switching it would re-identify the whole extension and rewrite every codec id. Drizzle usestypes.(a TS namespace), noteql., so there's no cross-adaptereql.precedent either.cipherstashFromStackV2(your pick).For @calvinbrewer (heads-up on your package)
cipherstash.EncryptedString(), which was never a valid v3 constructor (v3 text isText*). I made it a coherent v3 example (TextSearch/DoubleOrd/DateOrd/Json) and wireddb.tsto the v3 setup (cipherstashFromStackfrom/v3) so the snippet actually runs; please sanity-check it matches your intent.Copilot review follow-up
Addressed the stale pre-rename references Copilot flagged (error messages, doc comments, README wiring, and the bundling-isolation marker-collision note whose substring direction flipped after the rename). No behavioural change.
Verification
code:checkclean.properties.test.ts,migration-v3) are missing-devdep / needs-DB / needs-build issues on the branch, not this change.Changeset:
@cipherstash/prisma-nextminor (breaking, rc convention) +stashpatch (skill).https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
Summary by CodeRabbit
Breaking Changes
Encryptedprefix (e.g.,cipherstash.TextSearch(),cipherstash.Boolean()).cipherstashFromStack; usecipherstashFromStackV2for v2 contracts.textSearch,doubleOrd).Documentation
Tests